package com.i72.penetrate.touch;

import com.i72.basic.tools.BeanHelper;
import com.i72.basic.context.GlobalContext;
import org.springframework.beans.factory.BeanFactory;
import org.springframework.context.ApplicationContext;
import org.springframework.context.support.GenericApplicationContext;
import org.springframework.stereotype.Component;
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.stream.Collectors;

@Component
public class HttpTouchPlane implements TouchPlane {

    @Override
    public void registerTouchBean(ApplicationContext applicationContext) {

        BeanFactory factory = ((GenericApplicationContext) applicationContext).getBeanFactory();

        List<Class> classList = BeanHelper.scanPackage(Service.class,GlobalContext.getAPPPackage());

        classList = classList.stream().filter(i->i.toGenericString().contains("class")).collect(Collectors.toList());

        BeanHelper.registerBean(factory,false,false,classList);


    }

}
